#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int maxn=1e5+5;
int T,n,m,L,V;
int d[maxn],v[maxn],a[maxn];
int p[maxn];
struct Node{
	int l,r;
}g[maxn];
bool cmp(Node x,Node y){return x.l<y.l;}
int find(int x){
	return lower_bound(p+1,p+m+1,x)-p;
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%lld",&T);
	while(T--){
		scanf("%lld %lld %lld %lld",&n,&m,&L,&V);
		for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&d[i],&v[i],&a[i]);
		for(int i=1;i<=m;i++) scanf("%lld",&p[i]);
		int ans=0,cnt=0;
		for(int i=1;i<=n;i++){
			if(d[i]>p[m]) continue;
			if(a[i]==0){
				if(v[i]>V) if(find(d[i])!=m+1) {ans++;g[++cnt].l=find(d[i]);g[cnt].r=m;}
			}
			if(a[i]>0){
				if(v[i]>V) if(find(d[i])!=m+1) {ans++;g[++cnt].l=find(d[i]);g[cnt].r=m;}
				if(v[i]<=V){
					int s=(V*V-v[i]*v[i])/(a[i]*2)+1;
					if(find(s+d[i])!=m+1) {ans++;g[++cnt].l=find(s+d[i]);g[cnt].r=m;}
				}
			}
			if(a[i]<0){
				if(v[i]<V) continue;
				int s=(V*V-v[i]*v[i]+a[i]*2+1)/(a[i]*2);
				if(p[find(s+d[i])-1]>=d[i]) {ans++;g[++cnt].l=find(d[i]);g[cnt].r=find(s+d[i])-1;}
			}
			
			//printf("\n%d %d\n",i,ans);
		}
		printf("%lld ",ans);
		if(ans==0){printf("%lld\n",m);continue;}
		sort(g+1,g+cnt+1,cmp);
		//for(int i=1;i<=cnt;i++) printf("%d %d\n",g[i].l,g[i].r);
		ans=1;
		int book=g[1].r;
		for(int i=2;i<=cnt;i++){
			if(book<g[i].l) ans++,book=g[i].r;
			if(book>g[i].r) book=g[i].r;
		}
		printf("%lld\n",m-ans);
	}
    return 0;
}
